package me.zk.practice1.hw;

import java.util.Scanner;

public class HWBJ53 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int max =0;
        for (int i = 0; i < s.length(); i++) {
            if (Character.isDigit(s.charAt(i))) {
                char c = s.charAt(i);
                int j = i+1;
                int count =1;
                while (j < s.length()) {
                    if (Character.isDigit(s.charAt(i)) && Math.abs(c - s.charAt(j))<=1) {
                        count++;
                        c = s.charAt(j);
                        j++;
                    } else {
                        break;
                    }

                }
                max = Math.max(count,max);
            }
        }
        System.out.println(max);
    }
}
